//package com.parkinglot.management.common;
//
//
//import org.springframework.context.annotation.Configuration;
//import org.springframework.http.HttpStatus;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.servlet.HandlerExceptionResolver;
//import org.springframework.web.servlet.HandlerInterceptor;
//import org.springframework.web.servlet.ModelAndView;
//import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.PrintWriter;
//import java.util.HashMap;
//import java.util.List;
//
//@Configuration
//public class ErrorCode implements WebMvcConfigurer {
//
//    @Override
//    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(new HandlerInterceptor() {
//            @Override
//            public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//                if (request.getMethod().equals("GET")) {
//
//                    throw new ServiceException();
//
//                }
////                response.setStatus(400);
////                PrintWriter writer = response.getWriter();
////                writer.write("failed");
////                if (true) {
////                    throw new RuntimeException();
////                }
//                return false;
//            }
//        });
//    }
//
//    @Override
//    public void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> resolvers) {
//        resolvers.add(new HandlerExceptionResolver() {
//            @Override
//            public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) {
////                ModelAndView modelAndView = new ModelAndView();
////                modelAndView.setStatus(HttpStatus.BAD_GATEWAY);
////                HashMap<String, String> map = new HashMap<>();
////                map.put("test","failed");
////                modelAndView.addObject(map);
//                httpServletResponse.setStatus(400);
//
//                return null;
//            }
//        });
//    }
//
////    @Override
////    public void extendHandlerExceptionResolvers(List<HandlerExceptionResolver> resolvers) {
////
////    }
//}
